<?php
    include ($_SERVER['DOCUMENT_ROOT']."/CTAN/models/NgheSi.php");
    
    if(isset($_REQUEST['action'])){
        $nghesi = new NgheSi();
        $action=$_REQUEST['action'];
        if($action == 'update'){
            $nghesi->setId($_REQUEST['id']);
            $nghesi->setTenThat($_REQUEST["tenthat"]);
            $nghesi->setNgheDanh($_REQUEST["nghedanh"]);
            $nghesi->setNgaySinh($_REQUEST["ngaysinh"]);
            $nghesi->setLike($_REQUEST['like']);
            $nghesi->setTieuSu($_REQUEST["tieusu"]);
            $nghesi->setConHoatDong($_REQUEST['conhoatdong']);
            echo $nghesi->capNhatNgheSi();
        }elseif($action == 'delete'){
            $id = $_REQUEST['id'];
            $nghesi->setId($id);
            $result = $nghesi->xoaNgheSi();
            echo $result;
        }elseif($action == 'insert'){
            $nghesi->setTenThat($_REQUEST["tenthat"]);
            $nghesi->setNgheDanh($_REQUEST["nghedanh"]);
            $nghesi->setNgaySinh($_REQUEST["ngaysinh"]);
            $nghesi->setLike(0);
            $nghesi->setTieuSu($_REQUEST["tieusu"]);
            $nghesi->setConHoatDong(1);
            $result = $nghesi->themNgheSi();
            echo $nghesi->getTenThat();
        }
    }
    include_once $_SERVER['DOCUMENT_ROOT'].'/CTAN/views/NgheSi_DanhSach.php';
    include_once $_SERVER['DOCUMENT_ROOT'].'/CTAN/views/NgheSi_AdminTools.php';
    include_once $_SERVER['DOCUMENT_ROOT'].'/CTAN/views/NgheSi_ThongTin.php';
?>
